<html>
<head>
<meta charset="UTF-8">
<title>Devops导航页</title>
<link id="easyuiTheme" href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
<script src="../../ffres/dict/all.js" type="text/javascript"></script>
<link href="../../static/easyui/themes/frameless.css" rel="stylesheet" type="text/css"/>
<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<script type="text/javascript">

    function doAdd(){
        JLEUtil.createModalWin('新增', 'BpmBaseInfoAdd.html?bpmType=1');
    }

    function doUpdate() {
        var row = $('#dg').datagrid('getSelected');
        if (row){
            JLEUtil.createModalWin('修改', 'BpmBaseInfoUpdate.html?' + 'bpmId=' + row.bpmId);
        } else {
            $.messager.alert('提示','请选择一条记录！','info');
        }
    }

    function doEdit() {
        var row = $('#dg').datagrid('getSelected');
        if (row){
            var url = 'AutoBpmBaseInfoUpdateNewTab.html?&bpmId=${row.bpmId}';
            JLUtil.linkNewPage(url);
        } else {
            $.messager.alert('提示','请选择一条记录！','info');
        }
    }

    function doDelete(){
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $.messager.confirm('删除提示', '你确定要删除这条记录?', function(r){
                if (r){
                    var jsonData = JSON.parse('{'+'"bpmId":"' + row.bpmId + '"'+'}');
                    $.restfulDelete('../../api/bpm/base/info', jsonData, function(data) {
                        $.messager.alert('提示','记录删除成功!','info');
                        $('#dg').datagrid('reload');
                    });
                }
            });
        } else {
            $.messager.alert('提示','请选择一条记录！','info');
        }
    }

    function doView(){
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            JLEUtil.createModalWin('详情','BpmBaseInfoView.html?' + '&bpmId=' + row.bpmId);
        } else {
            $.messager.alert('提示','请选择一条记录！','info');
        }
    }

    //发布自动流程
    function doPublish() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            if("1" == row.bpmState){
                $.messager.alert('提示','所选流程已经发布!','info');
                return;
            }

            $.messager.confirm('提示', '是否确定发布自动流程?', function(r){
                if (r){
                    $.ajax({
                        type: 'POST',
                        url: '../../api/bpm/base/publish',
                        data: JSON.stringify(row),
                        contentType:"application/json;charset=utf-8",
                        dataType:"json",
                        async:false,
                        success: function(data) {
                            if(data){
                                reloadList();
                                $.messager.alert('提示','流程发布成功!','info');
                            }else{
                                $.messager.alert('错误','流程发布失败!','erro');
                            }
                        }
                    });
                }
            });
        } else {
            $.messager.alert('提示','请选择一条记录！','info');
        }
    }

    function doConfig(){
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            JLUtil.linkNewPage('BpaTaskInfoList.html?' + 'bpaId=' + row.bpmId);
        } else {
            $.messager.alert('提示','请选择一条记录！','info');
        }
    }

    function reloadList(){
        $('#dg').datagrid('reload');

        JLEUtil.closewin();
    };


    //获取url参数
    var subsCode=$.getUrlParam("subsCode");
    //获取列表
    function refreshResActList(categoryTag){
        //远程请求额外参数
        $('#dg').datagrid({
            queryParams: {
                subsCode: subsCode,
                categoryTag:categoryTag,
            }
        });
        //获取查询列表
        var bpmType = 1;
        $('#dg').datagrid({url : '../../api/bpm/base/infos/'+bpmType})
    }

    function addTab(title, url){
        if ($('#tt').tabs('exists', title)){
            $('#tt').tabs('select', title);
        } else {
            var content = '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:99%;"></iframe>';
            $('#tt').tabs('add',{
                title:title,
                content:content,
                closable:true
            });
        }
    }

    $(function(){
        //获取url参数
        var subsCode=$.getUrlParam("subsCode");

        //修改west标题为子系统名称
        $.restfulGet('../../api/s/subs/info/' + subsCode,null,function(data){
            if (data){
                var temp= $('#cc').layout("panel","west");
                temp.panel("setTitle",data.rows.subsName);
                $("#sysName").html(data.rows.subsName)
			}
        });
		var node = $('#menu_app1').tree('find', 'a11Li');
		$('#menu_app1').tree('select', node.target);
        addTab("应用信息","SysAppsInfoList.html?subsCode="+subsCode);
    });

</script>
</head>
<body id="cc" class="easyui-layout">
	<!-- 右侧  菜单资源树形栏 -->
	<div id="1" data-options="region:'west',title:'系统',split:true" style="width: 220px;">
		<div id="sm" data-toggle="topjui-sidemenu" data-options="data:data">
		</div>
		<div>

		<ul class="easyui-tree" data-options="animate:true,lines:true"
			id="menu_app1">
			<li><span><span id="sysName"></span></span>
			<ul>
				<li><span>资源管理</span>
				<ul>
					<li id="a11Li"><span><a id="a11"
							onclick="javascript:addTab($(this).text(),'SysAppsInfoList.html?subsCode='+subsCode)"
							target="centerFrame">应用信息</a></span></li>
					<li><span><a id="a12"
							onclick="javascript:addTab($(this).text(),'SysEcsInfoList.html?subsCode='+subsCode)"
							target="centerFrame">服务器信息</a></span></li>									
				</ul></li>
				<li><span>日常运维</span>
				<ul>
					<li><span><a id="a21"
							onclick="javascript:addTab($(this).text(),'ContinuousBpaList.html?subsCode='+subsCode+'&categoryTag=continuous')"
							target="centerFrame">持续部署</a></span></li>				
					<li><span><a id="a13"
							onclick="javascript:addTab($(this).text(),'SysDeployInfoList.html?subsCode='+subsCode)"
							target="centerFrame">应用运维</a></span></li>
					<li><span><a id="a14"
							onclick="javascript:addTab($(this).text(),'SSubsDatasourceList.html?subsCode='+subsCode)"
							target="centerFrame">数据库运维</a></span></li>	
					<li><span><a id="a42"
							onclick="javascript:addTab($(this).text(),'SSrvsCronConfList.html?subsCode='+subsCode)"
							target="centerFrame">定时运维</a></span></li>																		
				</ul></li>				
				<li><span>运维编排</span>
				<ul>
					<li><span><a id="a22"
							onclick="javascript:addTab($(this).text(),'AutoBpmBaseInfoList.html?subsCode='+subsCode+'&categoryTag=dataBackup')"
							target="centerFrame">运维流程编排</a></span></li>
					<li><span><a id="a23"
							onclick="javascript:addTab($(this).text(),'BpaInstInfoList.html?subsCode='+subsCode)"
							target="centerFrame">运维流程日志</a></span></li>
				</ul></li>			
			</ul></li>
		</ul>			
		</div>

	</div>
	<!-- 中间  内容主体 -->
	<div data-options="region:'center',border:false" title="" style="padding: 0px; background: #eee;">
		<!-- 资源操作 start -->
		<div class="easyui-panel" data-options="region:'center', border:'false'" style="height:99%">

			<div id="tt" class="easyui-tabs" fit="true" border="false" style="width:100%;height:95%">
			</div>

		</div><!-- 资源操作 end -->
	</div>
</body>
</html>
